package com.gitee.feizns.quickstart.mybatis.plus.query;

import com.gitee.feizns.dynamic.Strings;
import com.gitee.feizns.quickstart.web.advice.JsonPathFilterResponseBodyAdvice;
import lombok.Data;
import lombok.RequiredArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

/**
 * 配置
 * @author feizns
 * @since 2025/02/25
 */
@Data
public class Config {

    /**
     * 默认
     */
    public static final Config Default = new Config(){{
        this.ignoredFields.add(JsonPathFilterResponseBodyAdvice.jsonpathFilterRootParameterName);
        this.defaultOperator = "$eq";
    }};

    /**
     * 转换器类型
     */
    FieldConverterType fieldNameConversionStrategy = FieldConverterType.ToSnakeCase;

    /**
     * 忽略字段列表
     */
    List<String> ignoredFields = new ArrayList<>();

    /**
     * 默认的查询操作符
     */
    String defaultOperator;

    /**
     * 字段转换器类型
     * @author feizns
     * @since 2025/02/25
     */
    @RequiredArgsConstructor
    public enum FieldConverterType {

        /**
         * 转下划线
         */
        ToSnakeCase(Strings::toSnakeCase);

        /**
         * 转换器
         */
        public final Function<String, String> converter;

    }

}